﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Presentation.Controls
{
    public partial class Obra : System.Web.UI.UserControl
    {
        public string ImageUrl { get; set; }
        public bool IsVisible { get; set; }
        public int Height { get; set; }
        public string Text { get; set; }
        public string IdProyecto { get; set; }
        public bool Activo { get; set; }
        public bool IsObraImage { get; set; }
        protected void Page_Init(object sender, EventArgs e)
        {

        }
        protected void Page_Load(object sender, EventArgs e)
        {

            //ImagenProyecto.ImageUrl = ImageUrl;

            MainPanel.Visible = IsVisible;

            //Image

            ObraImageLink.ImageUrl = ImageUrl;
            ObraImageLink.Height = Height;

            ObraImage.Attributes["rel"] = "Image {" + Text + "}"; ;

            ObraImagenZoom.ImageUrl = ImageUrl;
            ObraImagenZoom.ImageTitle = Text;
            ObraImagenZoom.Width = 95;
            ObraImagenZoom.Height = 95;
            ObraImagenZoom.UseDivOverlay = true;
            ObraImagenZoom.Rel = Text;

            ObraImage.Attributes["onclick"] = "window.open('Proyecto_Detalle.aspx?idProyecto=" + IdProyecto + "','', config='height=600,width=1000, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no')";
            
            //Hyperlink

            ObraTextLink.Text = Text;
            ObraTextLink.Attributes["rel"] = "Text {" + Text + "}";
            ObraTextLink.Attributes["onclick"] = "window.open('Proyecto_Detalle.aspx?idProyecto=" + IdProyecto + "','', config='height=600,width=1000, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no')";

            ObraTextLinkPopUp.Text = Text;
            ObraTextLinkPopUp.Attributes["href"] = ImageUrl;
            ObraTextLinkPopUp.Attributes["rel"] = "Text {" + Text + "}" + " lightbox";
            ObraTextLinkPopUp.Attributes["title"] = Text;            
            
            divRedOverlay.Attributes["rel"] = Text;

            if (Activo)
            {
                ObraImageLink.Visible = true;
                ObraImagenZoom.Visible = false;
                ObraImage.Visible = true;                
                ObraTextLink.Visible = true;
                ObraTextLinkPopUp.Visible = false;
            }
            else
            {
                ObraImageLink.Visible = false;
                ObraImagenZoom.Visible = true;
                ObraTextLink.Visible = false;
                ObraTextLinkPopUp.Visible = true;
            }

            if (IsObraImage)            
                obraImageOverlayDiv.Visible = true;

            if (String.IsNullOrEmpty(Text) || IsObraImage)
            {
                ObraTextLink.Visible = false;
                ObraTextLinkPopUp.Visible = false;
            }

            if (!IsObraImage)
            {
                ObraImageLink.Visible = false;
                ObraImagenZoom.Visible = false;
            }
        }

        protected void btnOpenPopUp_OnClick(object sender, EventArgs e)
        {
        }
    }
}